﻿namespace _02.BankExersice.Accounts
{
    using System;
    using _02.BankExersice.Customers;

    public class Loan : Account
    {
        public Loan(Customer customer)
            : base(customer)
        {
        }

        public Loan(Customer customer, decimal interestRate, decimal balance)
            : base(customer, interestRate, balance)
        {
        }

        public override decimal CalculateInterestAmount(int numberOfMonths)
        {
            if ((this.Customer is IndividualCustomer) && (numberOfMonths > 3))
            {
                return (numberOfMonths - 3) * this.InterestRate * this.Balance;
            }
            else if ((this.Customer is CompanyCustomer) && (numberOfMonths > 2))
            {
                return (numberOfMonths - 2) * this.InterestRate * this.Balance;
            }
            else
            {
                return 0;
            }
        }
    }
}
